Function.prototype.mycall = function (obj, ...arr) {
  var obj = obj || window;
  obj.fn = this;

  var result = obj.fn(...arr);
  delete obj.fn;
  return result;
};
Function.prototype.myapply = function (obj, arr) {
  var obj = obj || window;
  obj.fn = this;

  var result = obj.fn(...arr);
  delete obj.fn;
  return result;
};

console.log("------------ call----------");

function sum(a, b, c) {
  console.log(this.aa);
  console.log(a + b + c);
}

var obj = { aa: 11 };
var re = sum.mycall(obj, '我的','名字是', 'lwt');
console.log(re);


console.log("------------ apply----------");
var re  = sum.myapply(obj,[1,2,3])